package com.ruoyi.project.channel.investConfig.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.channel.investConfig.domain.InvestConfig;
import com.ruoyi.project.channel.investConfig.service.IInvestConfigService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 充值配置信息操作处理
 * 
 * @author CAIN
 * @date 2021-01-30
 */
@Controller
@RequestMapping("/channel/investConfig")
public class InvestConfigController extends BaseController
{
    private String prefix = "channel/investConfig";
	
	@Autowired
	private IInvestConfigService investConfigService;
	
	@RequiresPermissions("channel:investConfig:view")
	@GetMapping()
	public String investConfig()
	{
	    return prefix + "/investConfig";
	}
	
	/**
	 * 查询充值配置列表
	 */
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(InvestConfig investConfig)
	{
		startPage();
        List<InvestConfig> list = investConfigService.selectInvestConfigList(investConfig);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出充值配置列表
	 */
	@RequiresPermissions("channel:investConfig:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(InvestConfig investConfig)
    {
    	List<InvestConfig> list = investConfigService.selectInvestConfigList(investConfig);
        ExcelUtil<InvestConfig> util = new ExcelUtil<InvestConfig>(InvestConfig.class);
        return util.exportExcel(list, "investConfig");
    }
	
	/**
	 * 新增充值配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存充值配置
	 */
	@RequiresPermissions("channel:investConfig:add")
	@Log(title = "充值配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(InvestConfig investConfig)
	{		
		return toAjax(investConfigService.insertInvestConfig(investConfig));
	}

	/**
	 * 修改充值配置
	 */
	@GetMapping("/edit/{investId}")
	public String edit(@PathVariable("investId") Long investId, ModelMap mmap)
	{
		InvestConfig investConfig = investConfigService.selectInvestConfigById(investId);
		mmap.put("investConfig", investConfig);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存充值配置
	 */
	@RequiresPermissions("channel:investConfig:edit")
	@Log(title = "充值配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(InvestConfig investConfig)
	{		
		return toAjax(investConfigService.updateInvestConfig(investConfig));
	}
	
	/**
	 * 删除充值配置
	 */
	@RequiresPermissions("channel:investConfig:remove")
	@Log(title = "充值配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(investConfigService.deleteInvestConfigByIds(ids));
	}
	
}
